home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / db / esm-3.1 / esm-3 / usr / local / sm / src / client / include / bf.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-05  |  7.9 KB  |  272 lines

  1. #ifndef __BF_H__
  2. #define __BF_H__
  3. /*
  4.  *   $RCSfile: bf.h,v $  
  5.  *   $Revision: 1.1.1.1 $  
  6.  *   $Date: 1996/05/04 21:55:19 $      
  7.  */ 
  8. /**********************************************************************
  9. * EXODUS Database Toolkit Software
  10. * Copyright (c) 1991 Computer Sciences Department, University of
  11. *                    Wisconsin -- Madison
  12. * All Rights Reserved.
  13. *
  14. * Permission to use, copy, modify and distribute this software and its
  15. * documentation is hereby granted, provided that both the copyright
  16. * notice and this permission notice appear in all copies of the
  17. * software, derivative works or modified versions, and any portions
  18. * thereof, and that both notices appear in supporting documentation.
  19. *
  20. * THE COMPUTER SCIENCES DEPARTMENT OF THE UNIVERSITY OF WISCONSIN --
  21. * MADISON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION.  
  22. * THE DEPARTMENT DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
  23. * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
  24. *
  25. * The EXODUS Project Group requests users of this software to return 
  26. * any improvements or extensions that they make to:
  27. *
  28. *   EXODUS Project Group 
  29. *     c/o David J. DeWitt and Michael J. Carey
  30. *   Computer Sciences Department
  31. *   University of Wisconsin -- Madison
  32. *   Madison, WI 53706
  33. *
  34. *     or exodus@cs.wisc.edu
  35. *
  36. * In addition, the EXODUS Project Group requests that users grant the 
  37. * Computer Sciences Department rights to redistribute these changes.
  38. **********************************************************************/
  39.  
  40. #include "forward.h"
  41. #include "resources.h"
  42. #include "error.h"
  43. #include "io.h"
  44. #include "object.h"
  45. #include "tid.h"
  46. #include "bf_macro.h"
  47.  
  48. /* BEGIN visible to E interpreter */
  49.  
  50. /*
  51.  * bf.h
  52.  *  Global defines, typedefs, etc. for the buffer manager.
  53.  */
  54.  
  55.  
  56. /*
  57.  * Next, the definition for page info structures.
  58.  */
  59. typedef struct PageInfo {
  60.  
  61.     int                bufIndex;       /* index of page in BufTable        */
  62.     TWO             blockCount;     /* number of blocks in this page    */
  63.     char            *bufFrame;      /* address of page in buffer pool   */
  64.     LIST            userList;       /* list of page user descriptors    */
  65.     PAGEHASH        *pageHash;      /* pointer to the hash structure    */
  66.     BUFINFO         *bufInfo;
  67.  
  68. } PAGEINFO;
  69.  
  70.  
  71.  
  72. /* END visible to E interpreter */
  73.  
  74. #include "PAGEHASH.h"
  75.  
  76.  
  77. /*
  78.  *  define intent modes passed to bf_ReadPage and its descendents
  79.  */
  80. #define INTENT_READ     1
  81. #define INTENT_WRITE    2
  82.  
  83.  
  84. /* BEGIN visible to E interpreter */
  85.  
  86. /*
  87.  * Definition for the BufGroup table.
  88.  * Buffer groups are used to implement a DBMIN-like replacement strategy.
  89.  * There are two lists associated with a buffer group, the group's
  90.  * fixed list and the groups unfixed list.
  91.  * 
  92.  * No fixed list is kept.
  93.  * The group's unfixed list is organized as a true list so that
  94.  * different replacement policies can be used.
  95.  * Note that a buffer region can simultaneously reside in several
  96.  * fixed lists but never in more than one unfixed list.
  97.  */
  98. typedef struct BufGroup {
  99.  
  100.     ONE     flags;                  /* state flags of group                 */
  101.     ONE     replacePolicy;          /* replacement policy for unfixed pages */
  102.     TWO     index;                  /* index of this group structure        */
  103.     int        maxCharges;             /* max charges allotted to the group    */
  104.     int        fixedCharges;           /* current fixed charges                */
  105.     int        unfixedCharges;         /* current unfixed charges              */
  106.     LIST    fixedList;              /* queue of fixed elements              */
  107.     LIST    unfixedList;            /* queue of unfixed elements            */
  108.     LISTELEMENT  groupList;         /* used for free/used lists             */  
  109.     LISTELEMENT  transList;         /* hangs off the transaction record     */
  110.  
  111.     MAGIC   magic;                  /* magic number for structure verify    */
  112. } BUFGROUP;
  113.  
  114.  
  115. #define BUFGROUP_MAGIC  0xef401cad
  116.  
  117. /* END visible to E interpreter */
  118.  
  119. /* BEGIN visible to user */
  120.  
  121. /*
  122.  *  Definition of flags for buffer groups
  123.  */
  124. #define G_FREE      0x0
  125. #define G_OPEN      0x1
  126. #define G_TRANS     0x2
  127.  
  128. /* added for client operation logging - MJF */
  129. #define LOG_GROUP   0x4
  130. #define FORCE_GROUP 0x8
  131.  
  132. /* END visible to user */
  133.  
  134. /* BEGIN visible to E interpreter */
  135.  
  136. /*
  137.  *  Definition of the entry to record 
  138.  */
  139. typedef struct GroupLink    {
  140.  
  141.     TWO             type;           /* flags field                      */
  142.     TWO             fixedCount;     /* number of times fixed in group   */
  143.     LISTELEMENT     hashList;       /* hung off list of structures      */
  144.     LISTELEMENT     groupList;      /* member of buffer group           */
  145.     PAGEHASH        *pageHash;      /* pointer to hash structure        */
  146.     BUFGROUP        *bufGroup;      /* pointer to the buffer group      */
  147.     char            *bufFrame;      /* pointer to the actual data       */
  148.  
  149.     MAGIC       magic;          /* for verification                 */
  150.  
  151. } GROUPLINK;
  152.  
  153. /*
  154.  *  define magic number
  155.  */
  156. #define GROUPLINK_MAGIC 0xbe4a20c8
  157.  
  158. /*
  159.  *  Flag that indicates this is a group link for a page
  160.  */
  161. #define TYPE_FREE   0x0 /* neither */
  162. #define TYPE_PAGE   0x1
  163. #define TYPE_CHUNK  0x2
  164.  
  165. /* END visible to E interpreter */
  166.  
  167. /*
  168.  *  Return values for the buffer groups
  169.  */
  170. #define BF_NOT_PRESENT  0
  171. #define BF_FREE         1
  172. #define BF_OTHER        2
  173. #define BF_FIXED        3
  174. #define BF_UNFIXED      4
  175.  
  176.  
  177. /* BEGIN visible to user */
  178. /* 
  179.  * Buffer replacement policies for buffer groups.
  180.  */
  181. #define BF_DEFAULT      0
  182. #define BF_LRU          1
  183. #define BF_MRU          2
  184. /* END visible to user */
  185.  
  186.  
  187. /*
  188.  *  Define some flags for use in the bf layer
  189.  * These are for the BFFLAGS type.
  190.  */
  191.  
  192. #define BF_SEM                  0x100
  193. #define BF_NOREAD               0x200
  194. #define BF_FORCE                0x400
  195. #define BF_WAIT                 0x800
  196.  
  197. /* BEGIN visible to user */
  198. typedef struct UserDesc {
  199.  
  200.     char        *basePtr;       /* ptr user will use to access data     */
  201.     int            byteCount;      /* bytes accessible to user             */
  202.     int            objectSize;     /* size of object                       */
  203.     TWO         userFlags;      /* properties field of the obj header   */
  204.     TWO         type;   
  205.     TWO         flags;          /* if this descriptor is valid          */
  206.     TWO         tag;            /* tag field from obj hdr               */
  207.     OID         oid;            /* oid of object being referenced       */
  208. /* END visible to user */
  209. /* BEGIN visible to E interpreter */
  210.     GROUPLINK   *groupLink;     /* ptr to the page's hash entry         */
  211.     BUFGROUP    *bufGroup;
  212.     char        *objInfo;       /* pointer to page info structure       */
  213.     TWO         objectSlot;
  214.     LISTELEMENT userList;       /* list of page users                   */
  215.     LISTELEMENT oidList;
  216.     LISTELEMENT transList;      /* hung off the transaction record      */
  217.     FID         fid;
  218.     int            offset;         /* starting offset of bytes in object   */
  219.     OID            forwardOid;     /* oid of the forwarded portion - if any*/
  220.  
  221.  
  222.     MAGIC       magic;          /* data structure magic verification    */
  223. /* END visible to E interpreter */
  224.  
  225. /* BEGIN visible to user */
  226. } USERDESC;
  227. /* END visible to user */
  228.  
  229.  
  230. /*
  231.  *  define magic number for page user descriptor
  232.  */
  233. #define USERDESC_MAGIC      0x54cae09a
  234.  
  235.  
  236. /*
  237.  *  Define flags for user descriptors
  238.  */
  239. #define USERDESC_FREE       0x0
  240. #define USERDESC_VALID      0x1
  241. #define USERDESC_DESTROYED  0x2
  242.  
  243.  
  244. #define SET_PAGEHASHLOCK(p, m)        { \
  245.     if (m == EX)  { \
  246.         p->writeLock = TransRec.clientTid; \
  247.         p->readLock = TransRec.clientTid; \
  248.         } \
  249.     else if (m == SH)  { \
  250.         p->writeLock = NULL_TID; \
  251.         p->readLock = TransRec.clientTid; \
  252.         } \
  253.     else { \
  254.         p->writeLock = NULL_TID; \
  255.         p->readLock = NULL_TID; \
  256.         } \
  257.     }
  258.  
  259. /* include these so that TransRec is defined: */
  260. #include "trans.h"
  261. #include "trans_globals.h"
  262.  
  263. #define GET_PAGEHASHLOCK(p, m)  {\
  264.     m = (p->writeLock == TransRec.clientTid) ? EX : \
  265.             ((p->readLock == TransRec.clientTid) ? SH : NL); \
  266.     }
  267.  
  268.     
  269. #define UNLOCKABLE_PAGE     (H_INDEX)
  270.  
  271. #endif __BF_H__
  272.